local guqin = fk.CreateSkill{
    name = "ym2__guqin",
}
Fk:loadTranslationTable{
    ["ym2__guqin"] = "骨琴",
    [":ym2__guqin"] = "你的初始手牌标记为“骨”不计入手牌上限，可当任意基本牌使用。当【酒】首次被使用时，你将所有手牌标记为“骨”且〖骨琴〗仅能转化为【酒】",
    ["@@ym2__guqin-inhand"] = "骨",
    ["@@ym2__guqin"] = "骨琴 酒",
    ["#ym2__guqin-basic"] = "骨琴：你可以将“骨”当任意基本牌使用",
    ["#ym2__guqin-analeptic"] = "骨琴：你可以将“骨”当【酒】使用",
}
guqin:addEffect("viewas",{
    pattern = ".|.|.|.|.|basic",
    prompt = function (self, player, selected_cards, selected)
        if player:getMark("@@ym2__guqin") ~= 0 then
           return "#ym2__guqin-analeptic"
        else
            return "#ym2__guqin-basic"
        end
    end,
    interaction = function(self, player)
        local all_names = Fk:getAllCardNames("b")
        if player:getMark("@@ym2__guqin") ~= 0 then
            all_names = {"analeptic"}
        end
        local names = player:getViewAsCardNames(guqin.name, all_names)
        if #names > 0 then
        return UI.CardNameBox { choices = names, all_choices = all_names }
        end
    end,
    handly_pile = true,
    card_filter = function(self, player, to_select, selected)
        return #selected == 0 and Fk:getCardById(to_select):getMark("@@ym2__guqin-inhand") > 0
    end,
    view_as = function(self, player, cards)
        if #cards ~= 1 or not self.interaction.data then return end
        local card = Fk:cloneCard(self.interaction.data)
        card:addSubcards(cards)
        card.skillName = guqin.name
        return card
    end,
    enabled_at_response = function (self, player, response)
        local all_names = Fk:getAllCardNames("b")
        if player:getMark("@@ym2__guqin") ~= 0 then
            all_names = {"analeptic"}
        end
        local names = player:getViewAsCardNames(guqin.name, all_names)
        return not response and #names > 0
    end,
})
guqin:addEffect(fk.GameStart, {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(guqin.name) and not player:isKongcheng()
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        for _, id in ipairs(player:getCardIds("h")) do
            room:setCardMark(Fk:getCardById(id), "@@ym2__guqin-inhand", 1)
        end
    end,
})
guqin:addEffect(fk.CardUsing,{
    can_trigger = function (self, event, target, player, data)
        local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
            return e.data.from == player and e.data.card.trueName == "analeptic"
        end, Player.HistoryGame)
        return player:hasSkill(guqin.name) and data.card.trueName == "analeptic" and #use_events == 1 and use_events[1].data == data
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"@@ym2__guqin",1)
        for _, id in ipairs(player:getCardIds("h")) do
            room:setCardMark(Fk:getCardById(id), "@@ym2__guqin-inhand", 1)
        end
    end,
})
guqin:addEffect("maxcards", {
    exclude_from = function(self, player, card)
        return card:getMark("@@ym2__guqin-inhand") > 0
    end,
})
guqin:addLoseEffect(function (self, player, is_death)
    local room = player.room
    for _, id in ipairs(player:getCardIds("h")) do
        room:setCardMark(Fk:getCardById(id), "@@ym2__guqin-inhand", 0)
    end
end)
return guqin